package com.rinlink.jbcodec.transform;

import com.rinlink.jbcodec.common.BytesUtils;
import com.rinlink.jbcodec.exception.TransformException;

import java.util.List;

public class CompositeTransformToBytes implements Transform<byte[]> {

    private List<Transform<byte[]>> transforms;

    public CompositeTransformToBytes(List<Transform<byte[]>> transforms) {
        this.transforms = transforms;
    }

    @Override
    public byte[] transform() throws TransformException {
        byte[][] arrays = new byte[transforms.size()][];
        for (int i = 0; i < arrays.length; i++)
            arrays[i] = transforms.get(i).transform();
        return BytesUtils.concat(arrays);
    }
}
